<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@  taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<%@ include file="common/head.jsp"%>

<body class="fix-header fix-sidebar">
	<!-- Preloader - style you can find in spinners.css -->
	<div class="preloader">
		<svg class="circular" viewBox="25 25 50 50">
				<circle class="path" cx="50" cy="50" r="20" fill="none"
				stroke-width="2" stroke-miterlimit="10" /> </svg>
	</div>
	<!-- Main wrapper  -->
	<div id="main-wrapper">
		<!-- header header  -->
		<%@ include file="common/header.jsp"%>
		<!-- End header header -->
		<!-- Left Sidebar  -->
		<%@ include file="common/nav.jsp"%>
		<!-- End Left Sidebar  -->
		<!-- Page wrapper  -->
		<div class="page-wrapper">
			<!-- 锐高软件 -->
			<%@ include file="../common/ruigao.jsp"%>

			<!--
                    	作者：offline
                    	时间：2018-03-26
                    	描述：查看信息
                    -->
			<div class="container-fluid">
				<!-- Start Page Content -->
				<div class="row justify-content-center">
					<div class="col-12">
						<div class="card">
							<div class="card-body">
								<div class="card-content">
									<!-- Left sidebar -->
									<div class="inbox-leftbar">
										<a class="btn btn-danger btn-block waves-effect waves-light"
											href="${pageContext.request.contextPath}/indexServlet"> <font
											style="vertical-align: inherit;"> <font
												style="vertical-align: inherit;">返回首页</font>
										</font>
										</a>

									</div>

								</div>
								<!-- End Left sidebar -->

								<div class="inbox-rightbar show">

									<div role="toolbar" class="">
										<div class="btn-group">
											<button class="btn btn-light waves-effect" type="button">
												<i class="mdi mdi-archive font-18 vertical-middle"></i>
											</button>
											<button class="btn btn-light waves-effect" type="button">
												<i class="mdi mdi-alert-octagon font-18 vertical-middle"></i>
											</button>
											<button class="btn btn-light waves-effect" type="button">
												<i class="mdi mdi-delete-variant font-18 vertical-middle"></i>
											</button>
										</div>

										<div class="btn-group">
											<button aria-expanded="false" data-toggle="dropdown"
												class="btn btn-light dropdown-toggle waves-effect"
												type="button">
												<font style="vertical-align: inherit;"><font
													style="vertical-align: inherit;"> 更多 </font></font><span
													class="caret m-l-5"></span>
											</button>

											<div class="dropdown-menu">

												<a href="applicationpag?status=1" class="dropdown-item">未通过</a>
												<a href="applicationpag?status=2" class="dropdown-item">已通过</a>
  							          </div>

										</div>
										<div class="btn-group">
											<button aria-expanded="false" data-toggle="dropdown"
												class="btn btn-light dropdown-toggle waves-effect"
												type="button">
												<font style="vertical-align: inherit;"><font
													style="vertical-align: inherit;">公司</font></font><span
													class="caret m-l-5"></span>
											</button>

											<div class="dropdown-menu">

												<%@ include file="../listall/companyall.jsp"%>
												<c:forEach var="sels" items="${selectcompany}">
													<a href="applicationpag?companyids=${sels.companyId}"
														class="dropdown-item"> ${sels.companyName}</a>
												</c:forEach>
											</div>

										</div>


									</div>

								</div>
								<div class="">
									<div class="mt-4">
										<table class="table">
											<thead>
												<tr>
													<th><font style="vertical-align: inherit;"> <font
															style="vertical-align: inherit;">申请人</font>
													</font></th>
													<th><font style="vertical-align: inherit;"> <font
															style="vertical-align: inherit;">标题</font>
													</font></th>

													<th><font style="vertical-align: inherit;"> <font
															style="vertical-align: inherit;">时间</font>
													</font></th>

													<th><font style="vertical-align: inherit;"> <font
															style="vertical-align: inherit;">操作</font>
													</font></th>

												</tr>

											</thead>
											<tbody>
												<c:forEach var="application"
													items="${ApplicationList.getPageList()}">
													<tr>

														<c:forEach var="user" items="${userList}">

															<c:if test="${application.userId eq user.userId}">
																<td><font style="vertical-align: inherit;">
																		<font style="vertical-align: inherit;">${user.userName}</font>
																</font></td>
															</c:if>

														</c:forEach>

														<td><font style="vertical-align: inherit;"> <font
																style="vertical-align: inherit;">${application.applicationTitle}</font>
														</font></td>

														<td><font style="vertical-align: inherit;"> <font
																style="vertical-align: inherit;">${application.applicationTime}</font>
														</font></td>

														<td class="showmessage">
															<button type="button" class="btn btn-success btn-sm btn-rounded m-b-2 m-l-5">
																<a href="${pageContext.request.contextPath}/applicationlist?tid=${application.applicationId}&opt=sel" style="color: white">查看</a>
															</button>
															<button type="button"
																class="btn btn-danger btn-sm btn-rounded m-b-2 m-l-5 del "
																name="del" value="${application.applicationId}">删除</button>
															<input type="hidden" name="opt" class="opt" value="">
														</td>
													</tr>
												</c:forEach>
											</tbody>

										</table>

									</div>

									<div class="table-responsive m-t-40">
										<div id="example23_wrapper" class="dataTables_wrapper">
											<div class="dataTables_paginate paging_simple_numbers"
												id="example23_paginate"> 

												<a href="applicationpag?PageNo=0&companyids=${CompanyId}&status=${Stuatus}&userid=${UserId}"
													class="paginate_button" aria-controls="example23"
													data-dt-idx="7" tabindex="0" id="example23"> <font
													style="vertical-align: inherit;"> <font
														style="vertical-align: inherit;"></font>首页
												</font>
												</a>
													<c:if test="${ApplicationList.getHasPrevPage() }">
														<a  href="applicationpag?pageNo=${ApplicationList.getPrevPage()}&companyids=${CompanyId}&status=${Stuatus}&userid=${UserId}" class="paginate_button previous disabled"
													aria-controls="example23" data-dt-idx="0" tabindex="0"
													id="example23_previous"><font
													style="vertical-align: inherit;"><font
														style="vertical-align: inherit;">上一页</font></font></a>
															</c:if>
														<span>
												
																<c:forEach items="${ApplicationList.groupPage }" var="pageI">
																	<a 	href="applicationpag?pageNo=${pageI }&companyids=${CompanyId}&status=${Stuatus}&userid=${UserId}"
													class="paginate_button " aria-controls="example23"
													data-dt-idx="${pageI }" tabindex="0"><font
														style="vertical-align: inherit;"><font
															style="vertical-align: inherit;">${pageI }</font></font></a>
																
																		</c:forEach>
													</span>
													
													<c:if test="${ApplicationList.getHasNextPage()  }">
									             	<a 	href="applicationpag?pageNo=${ApplicationList.getNextPage() }&companyids=${CompanyId}&status=${Stuatus}&userid=${UserId}"
													class="paginate_button next" aria-controls="example23"
													data-dt-idx="7" tabindex="0" id="example23_next"><font
													style="vertical-align: inherit;"><font
														style="vertical-align: inherit;">下一页</font></font></a>
													</c:if>
													
													
												<a href="applicationpag?PageNo=${ApplicationList.getTotalPage()}&companyids=${CompanyId}&status=${Stuatus}&userid=${UserId}"
													class="paginate_button" aria-controls="example23"
													data-dt-idx="7" tabindex="0" id="example23"> <font
													style="vertical-align: inherit;"> <font
														style="vertical-align: inherit;"></font>末页
												</font>
												</a>
											</div>
										</div>
									</div>



								</div>

							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- footer -->
		<%@ include file="common/footer.jsp"%>
		<!-- End footer -->
		<%@ include file="common/js.jsp"%>
		<!--
        	作者：offline
        	时间：2018-04-09
        	描述：点击删除按钮弹窗
        -->

		<script type="text/javascript">
			$(function() {
				//判断当前登录的员工的权限
			var competence = ${competence};
			if(competence!=3){
				$(".show").html("");
			}
				//点击删除
				$(".del")
						.click(
								function() {
									var dels = $(this).val();
									$(".opt").val("del");
									var del = $(".opt").val();
									swal(
											{
												title : "您确定要删除该申请吗？",
												animation : "slide-from-top",
												showCancelButton : true,
												closeOnConfirm : false,
												cancelButtonText : "取消",
												confirmButtonText : "确定"

											},
											function(inputValue) {
												if (inputValue === false)
													return false;
												$
														.ajax({
															url : "${pageContext.request.contextPath}/applicationlist",
															type : "GET",
															data : {
																"del" : dels,
																"opt" : del
															},
															datatype : "JSON",
															success : function(
																	data) {
																if (data) {
																	swal(
																			{
																				title : "删除成功,<span style='color:red'>已删除</span>申请",
																				html : true,
																				type : "success",
																				showCancelButton : false,
																				showConfirmButton : true,
																				confirmButtonText : "确定",
																			},
																			function() {
																				location
																						.reload();
																			});
																} else {
																	swal({
																		title : '删除失败！',
																		type : 'error',
																		confirmButtonText : '确定',
																		closeOnConfirm : false
																	});
																}
															},
															error : function(
																	data) {
																swal({
																	title : '操作失败！',
																	type : 'error',
																	confirmButtonText : '确定',
																	closeOnConfirm : false
																});
															}

														});
											});
								});

			});

			$(".waves-effect1").click(function() {

				var e = $(".optd").val();
				if (e > 1) {
					var index = $(".optd").val(e - 1);
				} else {
					var index = $(".optd").val(1);
				}

			})
			$(".waves-effect2").click(function() {
				var e = $(".optd").val();

				var coun = $(".coun").val();
				if (parseInt(coun) == parseInt(e)) {
					alert("没有更多页数了");
				} else {
					var index = $(".optd").val(parseInt(e) + 1);
				}

			})
		</script>
</body>

</html>